// constant.js （常量store）
import httpApi from '@/network/api'

export default {
	state: {
		orderStatusMap: {}, //订单状态键值映射
	},
	mutations: {
		// 赋值
		SET_ORDER_STATUS(state, info) {
			state.orderStatusMap = info;
		}
	},
	actions: {
		// 获取
		get_orderStatus({
			commit
		}) {
			httpApi.api.get_order_status().then(res => {
				commit('SET_ORDER_STATUS', res)
			})
		}
	},
	getters: {
		orderStatusMap: state => state.orderStatusMap, //订单状态键值映射
		orderStatusOptions: state => Object.entries(state.orderStatusMap).map(([k, v]) => ({
			value: k,
			label: v
		})), //订单状态options数组
	}
}